<template>
	<view class="comp-content">
		<view class="logBox" v-for="(logList,time) in state.list" :key="time" >
			<view class="logBox-time">
				{{timeFormat(time,'mm/dd日')}}
			</view>
			<view class="listBox">
				<view class="listBox-item ss-flex ss-col-top" v-for="list in logList" :key="`${time}-${list.id}`" @click="sheep.$router.go('/pages/store/shop',{id:list.store_id})">
					<image class="listBox-item-img ss-m-r-18" :src="sheep.$url.cdn(list.store.thumb||'/storage/storelevel/20250410/54cf8f23d18011b35a5d21159bfb31f9.png')" mode="aspectFill" />
					<view class="listBox-item-right ss-flex-1 ss-flex-col ss-row-between">
						<view class="rightBox-top ss-flex ss-row-between">
							<view class="top-left ss-flex-col ss-row-between">
								<view class="top-left-title">{{list.store.name}}</view>
								<view class="top-left-rate ss-flex">
									<uni-rate allow-half size="17" :value="list.store.mark" color="#bbb" active-color="#E36F39"/>
									<view class="top-left-rate-val ss-m-l-4">
										{{Number(list.store?.mark ||5).toFixed(1)}}
									</view>
								</view>
							</view>
							<button class="ss-reset-button top-btn">进店</button>
						</view>
						<view class="rightBox-bottom" v-if="list?.goods&&list.goods.length">
							<image class="rightBox-bottom-goods" :src="sheep.$url.cdn(goods.image)" v-for="goods in list.goods.slice(0,3)" mode="aspectFill"  @click.stop="sheep.$router.go('/pages/goods/index',{id:goods.id})" />
						</view>
					</view>
				</view>
			</view>
		</view>
		<uni-load-more  v-if="Object.keys(state?.list).length != 0" :contentText="{
			contentdown:'点击加载更多'
		}" :status="state.more"  @click="getList"/>
		<s-empty v-else-if="state.more == 'noMore'" :icon="sheep.$url.cdn('/mengchong/soldout-empty.png')" text="暂无记录"/>
	</view>
</template>

<script setup>
	import sheep from '@/sheep';
	import { reactive, computed, onMounted,nextTick } from 'vue'
	import { onLoad, onShow, onHide,onReachBottom } from '@dcloudio/uni-app';
	import {timeFormat} from "@/sheep/helper/index"
	const emit = defineEmits(['set'])
	const props = defineProps({
		data:{
			type:Object,
			default:()=>({})
		}
	})
	const state = reactive({
		page:0,
		more:'more',
		list:{}
	})
	onMounted(()=>{
		getList()
	})
	onReachBottom(()=>{
		
	})
	
	async function getList(){
		if(state.more == 'noMore') return uni.showToast({
			title:'没有更多了',
			icon:'none'
		})
		state.more = 'loading'
		let {error,data} = await sheep.$api.user.log.storeLog({
			list_rows:6,
			page:state.page + 1
		})
		if(error == 0){
			data.data.forEach((log)=>{
				console.log('111',log)
				let time = log.create_time.split(' ')[0]
				if(state.list[time]){
					state.list[time].push(log)
				}else{
					state.list[time] = [log]
				}
			})
			state.page = data.current_page
			state.more = data.data.length!=data.per_page  ? 'noMore':'more'
		}else{
			state.more = 'noMore'
		}
	}
	
</script>

<style lang="scss" scoped>
	.comp-content{
		.logBox{
			.logBox-time{
				margin: 20rpx 38rpx;
				width: 278rpx;
				height: 40rpx;
				font-family: Source Han Sans;
				font-size: 30rpx;
				font-weight: normal;
				line-height: 40rpx;
				letter-spacing: normal;
				color: #000000;
			}
			.listBox{
				.listBox-item{
					width: 710rpx;
					box-sizing: border-box;
					border-radius: 10rpx;
					background: #FFFFFF;
					margin: 20rpx 20rpx;
					padding: 14rpx 20rpx 20rpx;
					.listBox-item-img{
						width: 90rpx;
						min-width: 90rpx;
						height: 90rpx;
						border-radius: 10rpx;
					}
					.listBox-item-right{
						.rightBox-top{
							height: 90rpx;
							.top-left{
								height: 90rpx;
								.top-left-title{
									font-family: Source Han Sans;
									font-size: 30rpx;
									font-weight: 500;
									line-height: 40rpx;
									letter-spacing: normal;
									color: #000000;
								}
								.top-left-rate{
									.top-left-rate-val{
										vertical-align: bottom;
										font-family: Source Han Sans;
										font-size: 28rpx;
										font-weight: normal;
										line-height: 132.75%;
										letter-spacing: normal;
										color: #F6481E;
									}
								}
							}
							.top-btn{
								width: 110rpx;
								height: 60rpx;
								border-radius: 4rpx;
								background: #FCEFE5;
								font-family: Source Han Sans;
								font-size: 30rpx;
								font-weight: normal;
								line-height: 60rpx;
								letter-spacing: normal;
								color: #F6481E;
							}
						}
						.rightBox-bottom{
							margin-top: 20rpx;
							.rightBox-bottom-goods{
								margin-right: 10rpx;
								width: 180rpx;
								min-width: 180rpx;
								height: 180rpx;
								border-radius: 10rpx;
								background: #D8D8D8;
								vertical-align: bottom;
								&:last-child{
									margin-right: 0 !important;
								}
							}
						}
					}
				}
			}
		}
	}
</style>